<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.18"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>embedme: libemb::Socket Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="logo.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">embedme
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.18 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><b>libemb</b></li><li class="navelem"><a class="el" href="classlibemb_1_1_socket.html">Socket</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="#pro-attribs">Protected Attributes</a> &#124;
<a href="classlibemb_1_1_socket-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">libemb::Socket Class Reference<span class="mlabels"><span class="mlabel">abstract</span></span></div>  </div>
</div><!--header-->
<div class="contents">

<p>Socket抽象基类 <br  />
  
 <a href="classlibemb_1_1_socket.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="_socket_8h_source.html">Socket.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for libemb::Socket:</div>
<div class="dyncontent">
 <div class="center">
  <img src="classlibemb_1_1_socket.png" usemap="#libemb::Socket_map" alt=""/>
  <map id="libemb::Socket_map" name="libemb::Socket_map">
<area href="classlibemb_1_1_socket_c_a_n.html" title="CAN套接字" alt="libemb::SocketCAN" shape="rect" coords="0,56,144,80"/>
<area href="classlibemb_1_1_tcp_socket.html" title="TcpSocket类" alt="libemb::TcpSocket" shape="rect" coords="154,56,298,80"/>
<area href="classlibemb_1_1_udp_socket.html" title="UdpSocket类" alt="libemb::UdpSocket" shape="rect" coords="308,56,452,80"/>
<area href="classlibemb_1_1_local_tcp_socket.html" title="LocalTcpSocket类" alt="libemb::LocalTcpSocket" shape="rect" coords="154,112,298,136"/>
  </map>
</div></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a66ff2090729e8c677b9b74a8109f5c5e"><td class="memItemLeft" align="right" valign="top">virtual bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_socket.html#a66ff2090729e8c677b9b74a8109f5c5e">open</a> (std::string localAddr=&quot;&quot;, <a class="el" href="_base_type_8h.html#aebf3b8d3c22313714b07d595cc3effac">uint16</a> localPort=0)=0</td></tr>
<tr class="memdesc:a66ff2090729e8c677b9b74a8109f5c5e"><td class="mdescLeft">&#160;</td><td class="mdescRight">打开socket  <a href="classlibemb_1_1_socket.html#a66ff2090729e8c677b9b74a8109f5c5e">More...</a><br /></td></tr>
<tr class="separator:a66ff2090729e8c677b9b74a8109f5c5e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abe56fbd2d9b7e679a2fa123d3477d541"><td class="memItemLeft" align="right" valign="top">virtual bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_socket.html#abe56fbd2d9b7e679a2fa123d3477d541">close</a> ()</td></tr>
<tr class="memdesc:abe56fbd2d9b7e679a2fa123d3477d541"><td class="mdescLeft">&#160;</td><td class="mdescRight">关闭socket  <a href="classlibemb_1_1_socket.html#abe56fbd2d9b7e679a2fa123d3477d541">More...</a><br /></td></tr>
<tr class="separator:abe56fbd2d9b7e679a2fa123d3477d541"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adfdf7df8816e636aa1803d502b7451eb"><td class="memItemLeft" align="right" valign="top">virtual int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_socket.html#adfdf7df8816e636aa1803d502b7451eb">readData</a> (char *buf, int len)</td></tr>
<tr class="memdesc:adfdf7df8816e636aa1803d502b7451eb"><td class="mdescLeft">&#160;</td><td class="mdescRight">读取数据  <a href="classlibemb_1_1_socket.html#adfdf7df8816e636aa1803d502b7451eb">More...</a><br /></td></tr>
<tr class="separator:adfdf7df8816e636aa1803d502b7451eb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6b929e4664e4848e71647cd6494790a8"><td class="memItemLeft" align="right" valign="top">virtual int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_socket.html#a6b929e4664e4848e71647cd6494790a8">writeData</a> (const char *buf, int len)</td></tr>
<tr class="memdesc:a6b929e4664e4848e71647cd6494790a8"><td class="mdescLeft">&#160;</td><td class="mdescRight">写入数据  <a href="classlibemb_1_1_socket.html#a6b929e4664e4848e71647cd6494790a8">More...</a><br /></td></tr>
<tr class="separator:a6b929e4664e4848e71647cd6494790a8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a61157046df06f3b1b3966d1451223371"><td class="memItemLeft" align="right" valign="top">virtual int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_socket.html#a61157046df06f3b1b3966d1451223371">peekData</a> (char *buf, int len, int usTimeout=-1)</td></tr>
<tr class="memdesc:a61157046df06f3b1b3966d1451223371"><td class="mdescLeft">&#160;</td><td class="mdescRight">socket查看缓冲区数据  <a href="classlibemb_1_1_socket.html#a61157046df06f3b1b3966d1451223371">More...</a><br /></td></tr>
<tr class="separator:a61157046df06f3b1b3966d1451223371"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a953d731417a7e9a389080f407fe38543"><td class="memItemLeft" align="right" valign="top">virtual int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_socket.html#a953d731417a7e9a389080f407fe38543">recvData</a> (char *buf, int len, int usTimeout=-1)</td></tr>
<tr class="memdesc:a953d731417a7e9a389080f407fe38543"><td class="mdescLeft">&#160;</td><td class="mdescRight">socket接收数据  <a href="classlibemb_1_1_socket.html#a953d731417a7e9a389080f407fe38543">More...</a><br /></td></tr>
<tr class="separator:a953d731417a7e9a389080f407fe38543"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afdc396d85918fa1244322275d5612eca"><td class="memItemLeft" align="right" valign="top">virtual int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_socket.html#afdc396d85918fa1244322275d5612eca">sendData</a> (const char *buf, int len, int usTimeout=-1)</td></tr>
<tr class="memdesc:afdc396d85918fa1244322275d5612eca"><td class="mdescLeft">&#160;</td><td class="mdescRight">socket发送数据  <a href="classlibemb_1_1_socket.html#afdc396d85918fa1244322275d5612eca">More...</a><br /></td></tr>
<tr class="separator:afdc396d85918fa1244322275d5612eca"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aeb541b16c73f02af6a554e745787f9d0"><td class="memItemLeft" align="right" valign="top">virtual int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_socket.html#aeb541b16c73f02af6a554e745787f9d0">setOption</a> (int socketOpt, int value)</td></tr>
<tr class="memdesc:aeb541b16c73f02af6a554e745787f9d0"><td class="mdescLeft">&#160;</td><td class="mdescRight">设置socket选项  <a href="classlibemb_1_1_socket.html#aeb541b16c73f02af6a554e745787f9d0">More...</a><br /></td></tr>
<tr class="separator:aeb541b16c73f02af6a554e745787f9d0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a10c54ec0c3c3652b2ea89767188c0b1b"><td class="memItemLeft" align="right" valign="top">virtual int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_socket.html#a10c54ec0c3c3652b2ea89767188c0b1b">getOption</a> (int socketOpt)</td></tr>
<tr class="memdesc:a10c54ec0c3c3652b2ea89767188c0b1b"><td class="mdescLeft">&#160;</td><td class="mdescRight">获取socket选项  <a href="classlibemb_1_1_socket.html#a10c54ec0c3c3652b2ea89767188c0b1b">More...</a><br /></td></tr>
<tr class="separator:a10c54ec0c3c3652b2ea89767188c0b1b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5488b24c864a510fa9a6e2629d8f98dd"><td class="memItemLeft" align="right" valign="top">virtual bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_socket.html#a5488b24c864a510fa9a6e2629d8f98dd">setConnection</a> (std::string peerAddr, <a class="el" href="_base_type_8h.html#aebf3b8d3c22313714b07d595cc3effac">uint16</a> peerPort)</td></tr>
<tr class="memdesc:a5488b24c864a510fa9a6e2629d8f98dd"><td class="mdescLeft">&#160;</td><td class="mdescRight">设置连接(设置对端地址和端口)  <a href="classlibemb_1_1_socket.html#a5488b24c864a510fa9a6e2629d8f98dd">More...</a><br /></td></tr>
<tr class="separator:a5488b24c864a510fa9a6e2629d8f98dd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a17a82617775b44045f63455cbecf51e4"><td class="memItemLeft" align="right" valign="top">virtual bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_socket.html#a17a82617775b44045f63455cbecf51e4">getConnection</a> (std::string &amp;peerAddr, <a class="el" href="_base_type_8h.html#aebf3b8d3c22313714b07d595cc3effac">uint16</a> &amp;peerPort)</td></tr>
<tr class="memdesc:a17a82617775b44045f63455cbecf51e4"><td class="mdescLeft">&#160;</td><td class="mdescRight">获取连接(获取对端地址和端口)  <a href="classlibemb_1_1_socket.html#a17a82617775b44045f63455cbecf51e4">More...</a><br /></td></tr>
<tr class="separator:a17a82617775b44045f63455cbecf51e4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a701a6b1d84bfc872a4a9bc57c5005e6b"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_socket.html#a701a6b1d84bfc872a4a9bc57c5005e6b">isAlive</a> ()</td></tr>
<tr class="memdesc:a701a6b1d84bfc872a4a9bc57c5005e6b"><td class="mdescLeft">&#160;</td><td class="mdescRight">判断端口是否活动  <a href="classlibemb_1_1_socket.html#a701a6b1d84bfc872a4a9bc57c5005e6b">More...</a><br /></td></tr>
<tr class="separator:a701a6b1d84bfc872a4a9bc57c5005e6b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a82bea326e166ec56d8e2d8f3613a2285"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_socket.html#a82bea326e166ec56d8e2d8f3613a2285">fd</a> ()</td></tr>
<tr class="memdesc:a82bea326e166ec56d8e2d8f3613a2285"><td class="mdescLeft">&#160;</td><td class="mdescRight">获取端口fd  <a href="classlibemb_1_1_socket.html#a82bea326e166ec56d8e2d8f3613a2285">More...</a><br /></td></tr>
<tr class="separator:a82bea326e166ec56d8e2d8f3613a2285"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a39054e054af1de05a02f4d460298f4d6"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_socket.html#a39054e054af1de05a02f4d460298f4d6">fdopen</a> (int <a class="el" href="classlibemb_1_1_socket.html#a82bea326e166ec56d8e2d8f3613a2285">fd</a>)</td></tr>
<tr class="memdesc:a39054e054af1de05a02f4d460298f4d6"><td class="mdescLeft">&#160;</td><td class="mdescRight">通过fd打开端口  <a href="classlibemb_1_1_socket.html#a39054e054af1de05a02f4d460298f4d6">More...</a><br /></td></tr>
<tr class="separator:a39054e054af1de05a02f4d460298f4d6"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr class="memitem:aa3bb309e51bff6547c035e0d6b7c3e6a"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_socket.html#aa3bb309e51bff6547c035e0d6b7c3e6a">bindPort</a> (<a class="el" href="_base_type_8h.html#aebf3b8d3c22313714b07d595cc3effac">uint16</a> localPort, std::string localAddr=&quot;&quot;)</td></tr>
<tr class="memdesc:aa3bb309e51bff6547c035e0d6b7c3e6a"><td class="mdescLeft">&#160;</td><td class="mdescRight">绑定socket到指定IP地址的端口上  <a href="classlibemb_1_1_socket.html#aa3bb309e51bff6547c035e0d6b7c3e6a">More...</a><br /></td></tr>
<tr class="separator:aa3bb309e51bff6547c035e0d6b7c3e6a"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-attribs"></a>
Protected Attributes</h2></td></tr>
<tr class="memitem:a83e94aa9166cab327136e980d8ce7e12"><td class="memItemLeft" align="right" valign="top"><a id="a83e94aa9166cab327136e980d8ce7e12"></a>
std::string&#160;</td><td class="memItemRight" valign="bottom"><b>m_peerAddr</b> {&quot;&quot;}</td></tr>
<tr class="separator:a83e94aa9166cab327136e980d8ce7e12"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a22355ff0255fda5fa1f850a04ed7c33b"><td class="memItemLeft" align="right" valign="top"><a id="a22355ff0255fda5fa1f850a04ed7c33b"></a>
<a class="el" href="_base_type_8h.html#aebf3b8d3c22313714b07d595cc3effac">uint16</a>&#160;</td><td class="memItemRight" valign="bottom"><b>m_peerPort</b> {0}</td></tr>
<tr class="separator:a22355ff0255fda5fa1f850a04ed7c33b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2e519f10eb0b8891ebc88408e6b4dac0"><td class="memItemLeft" align="right" valign="top"><a id="a2e519f10eb0b8891ebc88408e6b4dac0"></a>
int&#160;</td><td class="memItemRight" valign="bottom"><b>m_sockfd</b> {-1}</td></tr>
<tr class="separator:a2e519f10eb0b8891ebc88408e6b4dac0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a96cf5d701a0bd44ba6173c5c565ee36a"><td class="memItemLeft" align="right" valign="top"><a id="a96cf5d701a0bd44ba6173c5c565ee36a"></a>
struct sockaddr_in&#160;</td><td class="memItemRight" valign="bottom"><b>m_localSockAddr</b></td></tr>
<tr class="separator:a96cf5d701a0bd44ba6173c5c565ee36a"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Socket抽象基类 <br  />
 </p>
</div><h2 class="groupheader">Member Function Documentation</h2>
<a id="aa3bb309e51bff6547c035e0d6b7c3e6a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa3bb309e51bff6547c035e0d6b7c3e6a">&#9670;&nbsp;</a></span>bindPort()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool libemb::Socket::bindPort </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="_base_type_8h.html#aebf3b8d3c22313714b07d595cc3effac">uint16</a>&#160;</td>
          <td class="paramname"><em>localPort</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::string&#160;</td>
          <td class="paramname"><em>localAddr</em> = <code>&quot;&quot;</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>绑定socket到指定IP地址的端口上 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">localPort</td><td>要绑定的端口 </td></tr>
    <tr><td class="paramname">localAddr</td><td>绑定的IP地址,不指定则为默认本机任意地址 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>成功返回true,失败返回false </dd></dl>

</div>
</div>
<a id="abe56fbd2d9b7e679a2fa123d3477d541"></a>
<h2 class="memtitle"><span class="permalink"><a href="#abe56fbd2d9b7e679a2fa123d3477d541">&#9670;&nbsp;</a></span>close()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool libemb::Socket::close </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>关闭socket </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">void</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>成功返回true,失败返回false </dd></dl>

<p>Reimplemented in <a class="el" href="classlibemb_1_1_socket_c_a_n.html#af29500cf81996e67ceaf210fa80c4e33">libemb::SocketCAN</a>, <a class="el" href="classlibemb_1_1_tcp_socket.html#a8c944c3e70eaef24dedfadf10c9a1116">libemb::TcpSocket</a>, and <a class="el" href="classlibemb_1_1_udp_socket.html#a4f2044f857353eecec12865ea3fffc90">libemb::UdpSocket</a>.</p>

</div>
</div>
<a id="a82bea326e166ec56d8e2d8f3613a2285"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a82bea326e166ec56d8e2d8f3613a2285">&#9670;&nbsp;</a></span>fd()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int libemb::Socket::fd </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>获取端口fd </p>
<dl class="section return"><dt>Returns</dt><dd>int </dd></dl>

</div>
</div>
<a id="a39054e054af1de05a02f4d460298f4d6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a39054e054af1de05a02f4d460298f4d6">&#9670;&nbsp;</a></span>fdopen()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool libemb::Socket::fdopen </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>fd</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>通过fd打开端口 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">fd</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true </dd>
<dd>
false </dd></dl>

</div>
</div>
<a id="a17a82617775b44045f63455cbecf51e4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a17a82617775b44045f63455cbecf51e4">&#9670;&nbsp;</a></span>getConnection()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool libemb::Socket::getConnection </td>
          <td>(</td>
          <td class="paramtype">std::string &amp;&#160;</td>
          <td class="paramname"><em>peerAddr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="_base_type_8h.html#aebf3b8d3c22313714b07d595cc3effac">uint16</a> &amp;&#160;</td>
          <td class="paramname"><em>peerPort</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>获取连接(获取对端地址和端口) </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">void</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>成功返回true,失败返回false </dd></dl>

</div>
</div>
<a id="a10c54ec0c3c3652b2ea89767188c0b1b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a10c54ec0c3c3652b2ea89767188c0b1b">&#9670;&nbsp;</a></span>getOption()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">int libemb::Socket::getOption </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>socketOpt</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>获取socket选项 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">socketType</td><td>SOCKET_TYPE_E </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>成功返回STATUS_OK,失败返回STATUS_ERROR </dd></dl>

</div>
</div>
<a id="a701a6b1d84bfc872a4a9bc57c5005e6b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a701a6b1d84bfc872a4a9bc57c5005e6b">&#9670;&nbsp;</a></span>isAlive()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool libemb::Socket::isAlive </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>判断端口是否活动 </p>
<dl class="section return"><dt>Returns</dt><dd>true </dd>
<dd>
false </dd></dl>

</div>
</div>
<a id="a66ff2090729e8c677b9b74a8109f5c5e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a66ff2090729e8c677b9b74a8109f5c5e">&#9670;&nbsp;</a></span>open()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual bool libemb::Socket::open </td>
          <td>(</td>
          <td class="paramtype">std::string&#160;</td>
          <td class="paramname"><em>localAddr</em> = <code>&quot;&quot;</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="_base_type_8h.html#aebf3b8d3c22313714b07d595cc3effac">uint16</a>&#160;</td>
          <td class="paramname"><em>localPort</em> = <code>0</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">pure virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>打开socket </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">localAddr</td><td></td></tr>
    <tr><td class="paramname">localPort</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true </dd>
<dd>
false </dd></dl>

<p>Implemented in <a class="el" href="classlibemb_1_1_local_tcp_socket.html#a001362c03715e2a34e3efca0483508ab">libemb::LocalTcpSocket</a>, <a class="el" href="classlibemb_1_1_tcp_socket.html#a5dc124f593f6e6e15e3de961290e9009">libemb::TcpSocket</a>, <a class="el" href="classlibemb_1_1_udp_socket.html#a68ff88290edd13f8093f61d405f4020c">libemb::UdpSocket</a>, and <a class="el" href="classlibemb_1_1_socket_c_a_n.html#a9d22e63de72acc671b452f13890471bf">libemb::SocketCAN</a>.</p>

</div>
</div>
<a id="a61157046df06f3b1b3966d1451223371"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a61157046df06f3b1b3966d1451223371">&#9670;&nbsp;</a></span>peekData()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">int libemb::Socket::peekData </td>
          <td>(</td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>buf</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>len</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>usTimeout</em> = <code>-1</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>socket查看缓冲区数据 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">buf</td><td>接收缓存 </td></tr>
    <tr><td class="paramname">len</td><td>缓存大小 </td></tr>
    <tr><td class="paramname">usTimeout</td><td>超时时间,-1:阻塞,0:立即返回,&gt;0:超时时间us </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>成功返回查看的数据长度,失败返回STATUS_ERROR </dd></dl>

</div>
</div>
<a id="adfdf7df8816e636aa1803d502b7451eb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#adfdf7df8816e636aa1803d502b7451eb">&#9670;&nbsp;</a></span>readData()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">int libemb::Socket::readData </td>
          <td>(</td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>buf</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>len</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>读取数据 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">buf</td><td></td></tr>
    <tr><td class="paramname">len</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>int </dd></dl>

<p>Reimplemented in <a class="el" href="classlibemb_1_1_udp_socket.html#a194c4197a7db27728ec2ea239a5fb695">libemb::UdpSocket</a>.</p>

</div>
</div>
<a id="a953d731417a7e9a389080f407fe38543"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a953d731417a7e9a389080f407fe38543">&#9670;&nbsp;</a></span>recvData()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">int libemb::Socket::recvData </td>
          <td>(</td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>buf</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>len</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>usTimeout</em> = <code>-1</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>socket接收数据 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">buf</td><td>接收缓存 </td></tr>
    <tr><td class="paramname">len</td><td>缓存大小 </td></tr>
    <tr><td class="paramname">usTimeout</td><td>超时时间,-1:阻塞,0:立即返回,&gt;0:超时时间us </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>成功返回接收的数据长度,失败返回STATUS_ERROR </dd></dl>

<p>Reimplemented in <a class="el" href="classlibemb_1_1_udp_socket.html#a992f02a6286ddfc53441b56a01c11eb1">libemb::UdpSocket</a>.</p>

</div>
</div>
<a id="afdc396d85918fa1244322275d5612eca"></a>
<h2 class="memtitle"><span class="permalink"><a href="#afdc396d85918fa1244322275d5612eca">&#9670;&nbsp;</a></span>sendData()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">int libemb::Socket::sendData </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>buf</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>len</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>usTimeout</em> = <code>-1</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>socket发送数据 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">data</td><td>发送数据缓存 </td></tr>
    <tr><td class="paramname">len</td><td>缓存大小 </td></tr>
    <tr><td class="paramname">usTimeout</td><td>超时时间,-1:阻塞,0:立即返回,&gt;0:超时时间us </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>成功返回发送的数据长度,失败返回STATUS_ERROR </dd></dl>

<p>Reimplemented in <a class="el" href="classlibemb_1_1_udp_socket.html#ac2c319002a9a7c2e945b9a337f79e031">libemb::UdpSocket</a>.</p>

</div>
</div>
<a id="a5488b24c864a510fa9a6e2629d8f98dd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5488b24c864a510fa9a6e2629d8f98dd">&#9670;&nbsp;</a></span>setConnection()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool libemb::Socket::setConnection </td>
          <td>(</td>
          <td class="paramtype">std::string&#160;</td>
          <td class="paramname"><em>peerAddr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="_base_type_8h.html#aebf3b8d3c22313714b07d595cc3effac">uint16</a>&#160;</td>
          <td class="paramname"><em>peerPort</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>设置连接(设置对端地址和端口) </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">void</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>成功返回true,失败返回false </dd></dl>

<p>Reimplemented in <a class="el" href="classlibemb_1_1_local_tcp_socket.html#a2c783361f400e753701d54d69388fd0c">libemb::LocalTcpSocket</a>, and <a class="el" href="classlibemb_1_1_tcp_socket.html#a7b4313971813566b203ad2cfc03278c0">libemb::TcpSocket</a>.</p>

</div>
</div>
<a id="aeb541b16c73f02af6a554e745787f9d0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aeb541b16c73f02af6a554e745787f9d0">&#9670;&nbsp;</a></span>setOption()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">int libemb::Socket::setOption </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>socketOpt</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>value</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>设置socket选项 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">socketType</td><td>SOCKET_TYPE_E </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>成功返回STATUS_OK,失败返回STATUS_ERROR </dd></dl>

</div>
</div>
<a id="a6b929e4664e4848e71647cd6494790a8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6b929e4664e4848e71647cd6494790a8">&#9670;&nbsp;</a></span>writeData()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">int libemb::Socket::writeData </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>buf</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>len</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>写入数据 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">buf</td><td></td></tr>
    <tr><td class="paramname">len</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>int </dd></dl>

<p>Reimplemented in <a class="el" href="classlibemb_1_1_udp_socket.html#a273ded5a5087037e54632f148f080f7a">libemb::UdpSocket</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>src/<a class="el" href="_socket_8h_source.html">Socket.h</a></li>
<li>src/Socket.cpp</li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.18
</small></address>
</body>
</html>
